package flc.ast.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.nettool.lib.TraceRouteInfo;

import org.jetbrains.annotations.NotNull;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

public class IpScanAdapter extends StkProviderMultiAdapter<TraceRouteInfo> {

    public IpScanAdapter() {
        super(1);
        addItemProvider(new MyItemProvider());
    }

    private class MyItemProvider extends BaseItemProvider<TraceRouteInfo> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_ip_scan;
        }

        @Override
        public void convert(@NotNull BaseViewHolder holder, TraceRouteInfo info) {
            holder.setText(R.id.tvIp, info.getIp());

            ImageView ivStatus = holder.getView(R.id.ivStatus);
            ivStatus.setSelected(info.isSuccessful());
        }
    }

}
